import {
  Component, OnInit, ViewEncapsulation, ChangeDetectionStrategy, ViewChild, Output,
  EventEmitter, Input
} from '@angular/core';
import {Router} from "@angular/router";
import {CrowdSkuResVO} from "@interface/index";



@Component({
  selector: 'buy-sku',
  templateUrl: './buy-sku.component.html',
  styleUrls: ['./buy-sku.component.scss'],
  encapsulation: ViewEncapsulation.None,
})
export class BuySkuComponent implements OnInit {

  public quantity = 1;
  @ViewChild('numModal') numModal; // 控制弹框的对象
  @Input() crowdSku: CrowdSkuResVO[];
  @Input() crowdCode;
  @Input() crowdLaunch;
  @Output() closeSkuSelect: EventEmitter<boolean> = new EventEmitter();

  constructor(public router: Router) {

  }

  ngOnInit() {
  }

  skuNumber(quantity) {
    this.quantity = quantity;
  }

  closeSku() {
    this.closeSkuSelect.emit();
  }

  goToConfirmOrder(skuCode, goodsCode) {
    this.router.navigate(['/order/confirm-order'], {
      queryParams: {
        skuCode: skuCode,
        quantity: this.quantity,
        goodsCateCode: goodsCode,
        crowdCode: this.crowdCode
      }
    });
  }

}
